package code;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String code = "";
        Scanner scanner = new Scanner(System.in);
        Random random = new Random();
        for (int i = 0; i < 5; i++) {
            int num = random.nextInt(3);// 0 1 2
            switch(num){
                case 0:{
                    char c = (char) (random.nextInt(26)+65);
                    code += c;
                    break;
                }
                case 1:{
                    char c = (char) (random.nextInt(26)+97);
                    code += c;
                    break;
                }
                case 2:{
                    code += random.nextInt(10);
                    break;
                }
                default:{
                    break;
                }
            }
        }
        System.out.println("验证码是:");
        System.out.println(code);
        System.out.println("输入验证码");
        String input = scanner.next();
        if(code.equals(input)){
            System.out.println("正确");
        }else{
            System.out.println("验证码错误");
        }
    }
}
